//
//  TrajectoryItemCell.m
//  BaseProject
//
//  Created by 王洋 on 2020/7/31.
//  Copyright © 2020 王洋. All rights reserved.
//

#import "TrajectoryItemCell.h"

@implementation TrajectoryItemCell

+ (CGFloat)calculateHeightWithWidth:(CGFloat)collectionWeidth {

    CGFloat height = ((collectionWeidth-40)/3) + 40;
    return height;
}

- (void)awakeFromNib {
    [super awakeFromNib];

//    [self.mainImageView sd_setImageWithURL:[NSURL URLWithString:@"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3498775058,1123193886&fm=26&gp=0.jpg"]];

}

- (void)fillCellWithModel:(commonTrajectoryModel *)model Type:(MyTrajectoryListType)type {


    
    [self.mainImageView sd_setImageWithURL:[NSURL URLWithString:model.url] placeholderImage:[UIImage imageNamed:@"placeholder"]];
    self.mainTitle.text = model.footName;
    
    if (model.price>0) {
        self.subTitle.text = [NSString stringWithFormat:@"¥%@",[Utilities changeDoubleToString:model.price]];
    } else {
        
    }
    
    switch (type) {
        case MyTrajectoryListType_package:{
            self.tagLab.text = @"套餐";
            self.subTitle.hidden = NO;
        } break;
        case MyTrajectoryListType_product:{
            self.tagLab.text = @"婚品";
            self.subTitle.hidden = NO;

        } break;
        case MyTrajectoryListType_case:{
            self.tagLab.text = @"案例";
            self.subTitle.hidden = YES;

        } break;
        default:
            break;
    }
}


- (void)layoutSubviews {
    [super layoutSubviews];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                
        [self pp_clipCorners:UIRectCornerAllCorners radius:6];
        [self.tagBG pp_clipCorners:UIRectCornerBottomRight radius:6];
    });
    
}

@end
